var a = getApp();

Page({
    data: {
        StatusBar: a.globalData.StatusBar,
        random: 0,
        min: 1,
        max: 100,
        ms: 3e3,
        running: !1
    },
    onShareAppMessage: function(a) {
        return {
            title: "随机数小程序",
            imageUrl: "https://wx3.sinaimg.cn/mw690/77d4598fgy1gblrrwj7crj20xa0u0aav.jpg"
        };
    },
    showModal: function(a) {
        this.setData({
            modalName: a.currentTarget.dataset.target
        });
    },
    hideModal: function() {
        this.setData({
            modalName: null
        });
    },
    start: function() {
        var a = this;
        if (!this.data.running) {
            this.setData({
                running: !0
            });
            var t = this.data.max, i = this.data.min, e = 0, n = setInterval(function() {
                a.setData({
                    random: Math.floor(Math.random() * (t - i + 1)) + i
                }), (e += 100) >= a.data.ms && (a.setData({
                    running: !1
                }), clearInterval(n));
            }, 100);
        }
    },
    minInput: function(a) {
        if ("" != a.detail.value) {
            var t = Number(a.detail.value);
            isNaN(t) && (t = 1), this.setData({
                min: t > this.data.max ? this.data.max : t
            });
        }
    },
    maxInput: function(a) {
        if ("" != a.detail.value) {
            var t = Number(a.detail.value);
            isNaN(t) && (t = 100), this.setData({
                max: t < this.data.min ? this.data.min : t
            });
        }
    },
    msInput: function(a) {
        if ("" != a.detail.value) {
            var t = 1e3 * Number(a.detail.value);
            (t < 3e3 || isNaN(t)) && (t = 3e3), this.setData({
                ms: t > 6e4 ? 6e4 : t
            });
        }
    }
});